package com.example.liumuyao.widgettest_412lmy;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.Switch;

public class NewActivity extends AppCompatActivity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_new);
        Intent intent = getIntent();
        String str = intent.getStringExtra("param1");
        int n = intent.getIntExtra("param2",10);
        //LogCat显示
        System.out.println("---"+str+"---"+String.valueOf(n));
        //Toast显示
        Toast.makeText(this,str+"---"+String.valueOf(n),Toast.LENGTH_SHORT);
        //在界面上的TextView中显示
        TextView TV = (TextView) findViewById(R.id.textView);
        TV.setText(str+"---"+String.valueOf(n));
        Button button=(Button)findViewById(R.id.button3);
        button.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button3:
                finish();
                break;
        }
    }
}
